from SimpleXMLRPCServer import SimpleXMLRPCServer
import xmlrpclib
from dataclasses import deviceSystem
import amara

class RPCRoot:
    pass

class DeviceSysRPC(deviceSystem):
    def loadtestxml(self):
        doc = amara.parse(u"data.xml")
        self.parseXMLAll(doc)
    def rpc_get_xml_all(self):
        return self.createXML().xml()
    def rpc_set_xml_all(self, xml):
        doc = amara.parse(xml)
        self.parseXMLAll(doc)
    def test_rpc(self):
        print 'blah'

root = RPCRoot()
root.DeviceSystem = DeviceSysRPC()
root.DeviceSystem.loadtestxml()

server = SimpleXMLRPCServer(("localhost", 8000), allow_none=True)
server.register_instance(root, allow_dotted_names=True)

try:
    print 'Use Control-C to exit'
    server.serve_forever()
except KeyboardInterrupt:
    print 'Exiting'
